package com.fingard.dsp.bank.directbank.cmbunion01;

import java.util.Map;

import com.fingard.dsp.bank.directConfig.ActSetItem;
import com.fingard.dsp.bank.directbank.bankInterface.IAcceptNotice;
import com.fingard.dsp.bank.directbank.cmbunion01.util.BoingPay;
import com.fingard.generalobj.NoticeReq;
import com.fingard.generalobj.NoticeResp;
import com.fingard.net.listener.SocketReceiver;

public class CMBUnion01AcceptNotice extends CMBUnion01Base implements
		IAcceptNotice {

	@Override
	public NoticeResp dealNotice(NoticeReq pNtReq) throws Exception {
		NoticeResp resp = new NoticeResp();
		resp.respBytes = "".getBytes(pNtReq.reqCharset);
		try{
	    	
	    	String p_req = pNtReq.getReqString();
	    	WriteBankLogLn("招商聚合支付通知报文：" + pNtReq.getFullString());
			//WriteBankLogLn("招商聚合支付通知报文："+p_req);
			ActSetItem actItem = this.getBankConfig().getActSetItem("1070497557869809664", "");
			if (actItem != null) {
				p_req = p_req.trim();
				Map<String, String> params = convertToMap(p_req.substring(0,p_req.length()-1));
				String[] RSApath = actItem.ownCertFilePath.split(",");
	            setConfig(actItem.ownKeyStorePath,actItem.oppCertFilePath,actItem.ownKeyPassword);
				
				boolean signVerified = BoingPay.verifySign(params);
				if (signVerified) {
					return resp;
				} else {
					return resp;
				}
			} else {
				return resp;
			}
			
			
		} catch(Exception e){
            WriteBankLogLn(e);
		}
		return resp;
	}

	@Override
	public void getContentLength(SocketReceiver p_receiver) throws Exception {
		// TODO Auto-generated method stub

	}

}
